﻿Public Class BorderOperation
    Inherits ImageOperationBase
    Private _size As Integer
    Private _color As Color
    Private _type As BorderType
    Public Sub New(ByVal Size As Integer, ByVal Color As Color, ByVal Type As BorderType)
        Me._size = Size
        Me._color = Color
        Me._type = Type
    End Sub
    Public Overrides Sub ExecuteExtension(ByRef g As System.Drawing.Graphics, ByRef b As System.Drawing.Bitmap)
        If _size > 0 Then
            Dim p1 As Point
            Dim p2 As Point
            Select Case _type
                Case BorderType.Left
                    p1 = New Point(0, 0)
                    p2 = New Point(0, b.Height)
                Case BorderType.Top
                    p1 = New Point(0, 0)
                    p2 = New Point(b.Width, 0)
                Case BorderType.Right
                    p1 = New Point(b.Width - _size, b.Height)
                    p2 = New Point(b.Width - _size, 0)
                Case BorderType.Bottom
                    p1 = New Point(0, b.Height - _size)
                    p2 = New Point(b.Width, b.Height - _size)
            End Select
            Dim p As New Pen(_color)
            p.Width = _size
            g.DrawLine(p, p1, p2)
        End If
    End Sub
End Class